<?php
namespace app\common\model;

use think\Model;

class Secure extends Model
{
    protected $autoWriteTimestamp = true;
    protected $type = [
        'secure_start'  =>  'timestamp:Y-m-d',
        'secure_end'  =>  'timestamp:Y-m-d',
        
    ];

    public function agency()
    {
        return $this->hasOne('Agency','id','agency_id')->field('id,name');
    }
    
    public function cars()
    {
        return $this->hasOne('Cars','car_id','car_id')->field('car_id,car_sn,car_unique_id,brand_id,agency_id');
    }
    
    public function scopeSecureNum($query,$time)
    {
        $query->where('secure_end','<',$time);
    }

}